﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wsn.ap;
using wsn.dao;
using wsn.model;

namespace wsn.svc
{
    
    public class DataService:IDataService
    {
        private AccessPointData data;
        private SensorDao sensorDao;
        public VerifyData verify;       //平滑处理等验证逻辑
        public DataReceive store;       //储存逻辑
        public DataService()
        {
            sensorDao = Daofactory.getSensorDao();
            store = FilterFactory.StoreData;
        }


        //设置要处理的数据
        public void setData(AccessPointData _data)
        {
            data = _data;
        }

        //对数据的处理
        public void execute()
        {
            Sensor s = sensorDao.findSensor(data.Sensor_ID, data.Sensor_Type);
            data.Sensor = s;

            if (verify != null)
            {
                if (verify(data) == false)
                    return;
            }
            data.Sensor.onReceive(data);
            store(data);
        }

    }
}
